package com.bnu.user.Controller;

import com.bnu.user.Entity.Result;
import com.bnu.user.Service.UserService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ：Zzy1211
 * @date ：Created in 2019/11/6 21:19
 * @description：
 * @modified By：
 * @version: $
 */
@RestController
@RequestMapping(value = "/user")
public class UserController {

    @Resource
    UserService userService;

    /**
     * 功能：测试
     * 接口格式：http://localhost:8080/user/hello
     */
    @RequestMapping("/hello")
    public String Hello(){
        return "hello!";
    }


    /**
     * 功能：用户登录
     * 接口格式：http://localhost:8080/user/login/账号/密码
     */
    @RequestMapping(value = "/login/{u_id}/{password}",method = RequestMethod.GET)
    public Result<String> login(@PathVariable("u_id") String u_id, @PathVariable("password") String password){
        return userService.login(u_id,password);
    }

    @RequestMapping(value = "/",method = RequestMethod.GET)
    public void initData(){
        userService.initUserData();
    }
}